//
//  ViewController.m
//  06-UINavgationtion
//
//  Created by GivenBmli on 16/7/21.
//  Copyright © 2016年 GivenBmli. All rights reserved.
//

#import "ViewController.h"
#import "PushViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    设置navigationBar的属性
//    1.title 告诉用户, 我这个视图控制器是干什么的
    self.title = @"sdadqf";
    self.navigationItem.title = @"qqqqqqqqw";
//    2.titleView 标题视图
    UISegmentedControl *segMent = [[UISegmentedControl alloc]initWithItems:@[@"韩旭",@"王煌"]];
    segMent.frame = CGRectMake(0, 0, 150, 44);
//    3.标题视图 , 修改x,y 对视图本身位置没影响
    self.navigationItem.titleView = segMent;
//    4.leftBarButtonItem
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(comeBack:)];
//    5.rightBarButtonItem
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)];
//    6.
    UIBarButtonItem *barButtonItemTitle =[[UIBarButtonItem alloc]initWithTitle:@"xxx" style:UIBarButtonItemStylePlain target:self action:@selector(comeBack:)];
    UIBarButtonItem *barButtonItemSystemItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)];
    self.navigationItem.leftBarButtonItems = @[barButtonItemTitle,barButtonItemSystemItem, barButtonItemSystemItem, barButtonItemSystemItem];
//    7.rightBarButtonItems 数组
//    barBarButtonItems数组中放1~2个Item为优
//    8.隐藏navigationBar Yes 隐藏 NO 不隐藏 默认NO
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.hidden = NO;
//    9.navigationBar背景样式Default
//    self.navigationController.navigationBar.barStyle  = UIBarStyleBlack;
//    10. navigationBar 的背景颜色
//    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
//    11.导航栏颜色
    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
//    12.tintColor 导航栏元素的颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
//    13.translucent 管理半透明效果, yes开启, NO为关闭
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(0, 0, 100, 100);
    button.backgroundColor = [UIColor blueColor];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];

//    设置Yes self.view 坐标系从原点开始
//    设置NO self.view 坐标系从navigationBar 下开始;
    self.navigationController.navigationBar.translucent = NO;
//     14.改变坐标系 与translucent 为NO时效果一样
//    self.editing = UIRectEdgeNone;
//    页面跳转
//    1.push 入栈 pushViewController
//    2.pop 出栈 popViewControllerAnimated
//    3.viewControllers 存放 navigationController里所有控制器
//    4.topViewController 栈顶视图控制器
//    5.visibIViewController 可见视图控制器
//    self.navigationController.viewControllers
    
}

- (void)buttonClicked:(UIButton *)button {
//    将视图控制器
    [self.navigationController pushViewController:[[PushViewController alloc] init] animated:YES];
}

- (void)comeBack:(UIBarButtonItem *)barButtonIetm {
    NSLog(@"afadf");
}

- (void)add:(UIBarButtonItem *)barButtonIetm{
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
